import myAxios from "../plugins/myAxios.ts";
import {getCurrentUserState, setCurrentUserState} from "../states/user.ts";

export const getCurrentUser = async () => {
    // const currentUser =  getCurrentUserState()
    // if (currentUser) {
    //     return currentUser;
    // }
    // 不存在请求后端获取当前用户
    const res: any = await myAxios.get('/user/currentUser')
    if (res.code === 0) {
        setCurrentUserState(res.data);
        return res.data;
    }
    return null;
}